package com.neutech.solar.util;

import com.neutech.solar.constant.Constant;
import com.sun.javafx.collections.MappingChange;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

//工具类
public class ImageUtil {
    public static Map<String,Image> maps = new HashMap<>();
    static {
        maps.put("sky", ImageUtil.getImage("sky01.jpg"));
        maps.put("smallPlanet", ImageUtil.getImage("00Ceres.png"));
        maps.put("earth", ImageUtil.getImage("04earth.png"));
        maps.put("mars", ImageUtil.getImage("06mars.png"));
        maps.put("mercury", ImageUtil.getImage("02mercury.png"));
        maps.put("venus", ImageUtil.getImage("03venus.png"));
        maps.put("jupiter", ImageUtil.getImage("07jupiter.png"));
        maps.put("saturn", ImageUtil.getImage("08saturn.png"));
        maps.put("uranus", ImageUtil.getImage("09uranus.png"));
        maps.put("neptune", ImageUtil.getImage("010neptune.png"));
        maps.put("pluto", ImageUtil.getImage("011pluto.png"));
        maps.put("Ceres", ImageUtil.getImage("00Ceres.png"));
        maps.put("shower",ImageUtil.getImage("shower01.png"));
    }
    public ImageUtil() {
    }
    public static Image getImage(String imagePath){
        URL url = ImageUtil.class.getClassLoader().getResource(Constant.IMAGE_PATH+imagePath);
        BufferedImage image = null;
        try {
            image = ImageIO.read(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return image;
    }
}
